package com.itheima.api;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.itheima.mapper.OmsOrderSettingMapper;
import com.itheima.pojo.OmsOrderSetting;
import com.itheima.vo.MinioVo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author 芝士雪豹
 * @create 2022/10/15/19:45
 */
@DubboService
public class OmsOrderSettingApiImpl implements OmsOrderSettingApi {
    @Autowired
    private OmsOrderSettingMapper mapper;

    @Override
    public MinioVo findOne(Integer id) {
        MinioVo vo = new MinioVo();
        OmsOrderSetting omsOrderSetting = mapper.selectById(id);
        if (omsOrderSetting!=null){
            vo.setCode(200);
            vo.setDate(omsOrderSetting);
            vo.setMessage("获取数据成功");
            return vo;
        }
        vo.setCode(500);
        vo.setDate(null);
        vo.setMessage("暂无数据修改");
        return vo;
    }

    @Override
    public MinioVo update(Integer id, OmsOrderSetting dto) {
        //LambdaUpdateWrapper<OmsOrderSetting> wrapper = new LambdaUpdateWrapper<>();
        //wrapper.eq(id!=null,OmsOrderSetting::getId,id)
        //        .set(dto.getCommentOvertime()!=null,OmsOrderSetting::getCommentOvertime,dto.getCommentOvertime())
        //        .set(dto.getConfirmOvertime()!=null,OmsOrderSetting::getConfirmOvertime,dto.getConfirmOvertime())
        //        .set(dto.getFinishOvertime()!=null,OmsOrderSetting::getFinishOvertime,dto.getFinishOvertime())
        //        .set(dto.getFlashOrderOvertime()!=null,OmsOrderSetting::getFlashOrderOvertime,dto.getFlashOrderOvertime())
        //        .set(dto.getNormalOrderOvertime()!=null,OmsOrderSetting::getNormalOrderOvertime,dto.getNormalOrderOvertime());
        //int update = mapper.update(null, wrapper);
        dto.setId(id.longValue());
        int i = mapper.updateById(dto);
        MinioVo vo = new MinioVo();
        if (i!=0){
            vo.setCode(200);
            vo.setDate(null);
            vo.setMessage("修改成功");
            return vo;
        }
        vo.setCode(500);
        vo.setDate(null);
        vo.setMessage("暂无数据修改");
        return vo;
    }
}
